package com.miracle9.game.dao;
import com.miracle9.game.entity.GameDataLog;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;

@Repository
public class GameDataLogServiceDao extends SqlOperating<GameDataLog, Integer>
{
  public void deleteByDate(String date)
  {
	  q_CreateSql("delete from GameDataLog where datetime like ?", new Object[] { date + "%" }).executeUpdate();
  }
  
  public List<Object[]> getListByDateAndType(String hql, String date, int type)
  {
    SQLQuery query = null;
    if (type == -1) {
      query = s_CreateSql(hql, new Object[] { date + "%" });
    } else {
      query = s_CreateSql(hql, new Object[] { date + "%", Integer.valueOf(type) });
    }
    return query.list();
  }
  
  public List<Object[]> getListByDateIntervalResult(String hql, String startDate, String endDate, int firstResult, int maxResults)
  {
    SQLQuery query = null;
    query = s_CreateSql(hql, new Object[] { startDate, endDate + "%", Integer.valueOf(firstResult), Integer.valueOf(maxResults) });
    return query.list();
  }
  
  public List<Object[]> getListByDateInterval(String hql, String startDate, String endDate)
  {
    SQLQuery query = null;
    query = s_CreateSql(hql, new Object[] { startDate, endDate });
    return query.list();
  }
}
